<?php 
namespace Admin\Controller;
use Think\Controller;
class DoctypeController extends BaseController{
	public function index(){
		$Model=M('share_group');
		$Share=M('share');
		$start=I('get.start');//开始id
		$limit=10000;//每次10000条
		if (!$start) {
			$max_id=$Model->field(max('sid'))->find();
			$start=$max_id['sid'];
		}
		$rs=$Share->field('id,doctype')->limit($start,($start+$limit))->select();
// 		print_r($rs);
		for ($i=0;$i<count($rs);$i++){
			$data[$i]['sid']=$rs[$i]['id'];
			if ($rs[$i]['doctype']) {
				$data[$i]['doctype']=$this->doctype2number(strtolower($rs[$i]['doctype']));
			}else{
				//folder
				$data[$i]['doctype']=9;
			}
		}
		$Model->addAll($data);
		print_r($data);
		
		
	}
	
	private function doctype2number($doctype){
		$bt=array('torrent');
		if (in_array($doctype,C('VIDEO'))) {
			//视频 1
			return 1;
		}elseif (in_array($doctype,C('MUSIC'))){
			//音乐 2
			return 2;
		}elseif (in_array($doctype,C('PIC'))){
			//图片 4
			return 4;
		}elseif (in_array($doctype,c('ZIP'))){
			//压缩资源 9
			return 9;
		}elseif (in_array($doctype,C('BOOK'))){
			//文档资源 3
			return 3;
		}elseif (in_array($doctype,$bt)){
			//bt种子 5
			return 5;
			
		}elseif (in_array($doctype,C('SOFTWARE'))){
			//软件 6
			return 6;
		}else{
			//其它 0
			return 0;
		}
		
	}
	
	
	public function from(){
		echo $_SERVER['HTTP_REFERER'];
		echo $type=I('get.type');die();
	}
	

}
